Service
Tip
The OpenAPI described in this document applies to K8s YAML services.
# Get Service List
# Test Service
Request
GET /openapi/service/yaml/services?projectKey=<projectKey>
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Response Description
| Parameter Name | Type | Description |
|---|---|---|
service_name | string | Service name |
type | string | Service type, fixed value k8s |
containers | []Container | List of service components |
Container Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
name | string | Service component name |
image | string | Service component image |
image_name | string | Service component image name |
Response Example
Details
{
"service": [
{
"service_name": "service-1",
"type": "k8s",
"containers": [
{
"name": "myapp-1",
"image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:v0.1__linux_amd64",
"image_name": "myapp-1"
}
]
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Production Service
Request
GET /openapi/service/yaml/production/services?projectKey=<projectKey>
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Response Description
| Parameter Name | Type | Description |
|---|---|---|
service_name | string | Service name |
type | string | Service type, fixed value k8s |
containers | []Container | List of service components |
Container
| Parameter Name | Type | Description |
|---|---|---|
name | string | Service component name |
image | string | Service component image |
image_name | string | Service component image name |
Response Example
Details
[
{
"service_name": "service-1",
"type": "k8s",
"containers": [
{
"name": "myapp-1",
"image": "koderover.tencentcloudcr.com/koderover-demo/myapp-1:v0.1__linux_amd64",
"image_name": "myapp-1"
}
]
}
]
2
3
4
5
6
7
8
9
10
11
12
13
# Get Service Details
# Test Service
Request
GET /openapi/service/yaml/:serviceName?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Response Description
| Parameter Name | Type | Description |
|---|---|---|
service_name | string | Service name |
created_by | string | Service creator |
created_time | int | Service creation time |
type | string | Service type, fixed value k8s |
containers | []Container | Service component list |
service_variable_kvs | []KeyVal | Service variable list |
yaml | string | Service configuration YAML content |
Container Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
name | string | Service component name |
image | string | Service component image |
image_name | string | Service component image name |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Response Example
Details
{
"service_name": "service2",
"type": "k8s",
"created_by": "admin",
"created_time": 1689660993,
"yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service2\n labels: \n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: test\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: {{.world}}\n spec:\n containers:\n - name: service2\n image: koderover.******.com/koderover-demo/service2:latest\n imagePullPolicy: Always \n command:\n - /workspace/service2\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service2\n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}",
"containers": [
{
"name": "service2",
"image": "koderover.******.com/koderover-demo/service2:latest",
"image_name": "service2"
}
],
"service_variable_kvs": [
{
"key": "cpuLimit",
"value": "55m",
"type": "string",
"options": [],
"desc": ""
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Production Service
Request
GET /openapi/service/yaml/production/:serviceName?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Response Description
| Parameter Name | Type | Description |
|---|---|---|
service_name | string | Service name |
created_by | string | Service creator |
created_time | int | Service creation time |
type | string | Service type, fixed value k8s |
containers | []Container | Service component list |
service_variable_kvs | []KeyVal | Service variable list |
yaml | string | Service configuration YAML content |
Container Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
name | string | Service component name |
image | string | Service component image |
image_name | string | Service component image name |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Response Example
Details
{
"service_name": "service2",
"type": "k8s",
"created_by": "admin",
"created_time": 1689660993,
"yaml": "apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service2\n labels: \n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: test\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\n hello: {{.world}}\n spec:\n containers:\n - name: service2\n image: koderover.******.com/koderover-demo/service2:latest\n imagePullPolicy: Always \n command:\n - /workspace/service2\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service2\n labels:\n app.kubernetes.io/name: ai-test-2\n app.kubernetes.io/instance: service2\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}",
"containers": [
{
"name": "service2",
"image": "koderover.******.com/koderover-demo/service2:latest",
"image_name": "service2"
}
],
"service_variable_kvs": [
{
"key": "cpuLimit",
"value": "55m",
"type": "string",
"options": [],
"desc": ""
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Get Service Labels
Request
GET /openapi/service/yaml/:serviceName/labels?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Response Example
Correct return
[
{
"key": "key",
"value": "value"
},
...
]
2
3
4
5
6
7
Error return
{
"code": 500,
"description": "...",
"message": "Internal Error"
}
2
3
4
5
# Create New Service Using Template
# Test Service
Request
POST /openapi/service/template/load/yaml
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_name | Service name | string | Yes |
project_key | Project key | string | Yes |
template_name | K8s Yaml Template Name | string | Yes |
auto_sync | Auto sync switch | bool | No |
variable_yaml | Template variable information | []KeyVal | No |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key value | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
Body Parameter Example
Use template microservice-template to create service service1 for project demo:
Details
{
"service_name": "service1",
"project_key":"demo",
"template_name": "microservice-template",
"auto_sync": true,
"variable_yaml": [
{
"key": "cpuLimit",
"value": "100m"
},
{
"key": "memoryLimit",
"value": "100Mi"
},
{
"key": "port",
"value": "20221"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Return
{
"message": "success"
}
2
3
# Production Service
Request
POST /openapi/service/template/production/load/yaml
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_name | Service name | string | Yes |
yaml | Service YAML content | string | Yes |
project_key | Project key | string | Yes |
template_name | K8s Yaml Template Name | string | Yes |
auto_sync | Auto sync switch | bool | No |
variable_yaml | Template variable information | []KeyVal | No |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key value | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
Body Parameter Example
Use template base-template to create service service1 for project demo:
Details
{
"service_name": "service1",
"production":true,
"project_key":"demo",
"template_name":"base-template",
"auto_sync":true,
"variable_yaml":[
{
"key":"cpuLimit",
"value":"15m"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
Return
{
"message": "success"
}
2
3
# Create New Service Manually
# Test Service
Request
POST /openapi/service/yaml/raw?projectKey=<projectKey>
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_name | Service name | string | Yes |
yaml | Service YAML content | string | Yes |
variable_yaml | yaml variable information | []KeyVal | No |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Body Parameter Example
Details
{
"service_name":"service-3",
"yaml":"apiVersion: v1\nkind: Service\nmetadata:\n name: a\n labels:\n app: a\nspec:\n ports:\n - name: http\n port: 80\n targetPort: 8080\n selector:\n app: a\n\n---\n\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: a\n labels:\n app: a\nspec:\n selector:\n matchLabels:\n app: a\n replicas: 1\n template:\n metadata:\n labels:\n app: a\n spec:\n containers:\n - name: myapp-1\n image: koderover.******.com/koderover-demo/myapp-1:v0.1__linux_amd64\n imagePullPolicy: Always\n command: [\"/myapp-1\"]\n args: [\"--downstream-addr\", \"$(DOWNSTREAM_ADDR)\", \"--headers\", \"$(HEADERS)\"]\n env:\n - name: DOWNSTREAM_ADDR\n value: \"b\"\n - name: HEADERS\n value: \"x-request-id\"\n ports:\n - containerPort: 8080\n resources:\n limits:\n cpu: {{.cpu}}\n memory: 122Mi\n",
"variable_yaml":[
{
"key":"cpu",
"value":"12m",
"desc":"cpu value",
"type":"string"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
Return
{
"message": "success"
}
2
3
# Production Service
Request
POST /openapi/service/yaml/production/raw?projectKey=<projectKey>
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_name | Service name | string | Yes |
yaml | Service YAML content | string | Yes |
variable_yaml | yaml variable information | []KeyVal | No |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Body Parameter Example
Details
{
"service_name":"service-3",
"yaml":"apiVersion: v1\nkind: Service\nmetadata:\n name: a\n labels:\n app: a\nspec:\n ports:\n - name: http\n port: 80\n targetPort: 8080\n selector:\n app: a\n\n---\n\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: a\n labels:\n app: a\nspec:\n selector:\n matchLabels:\n app: a\n replicas: 1\n template:\n metadata:\n labels:\n app: a\n spec:\n containers:\n - name: myapp-1\n image: koderover.******.com/koderover-demo/myapp-1:v0.1__linux_amd64\n imagePullPolicy: Always\n command: [\"/myapp-1\"]\n args: [\"--downstream-addr\", \"$(DOWNSTREAM_ADDR)\", \"--headers\", \"$(HEADERS)\"]\n env:\n - name: DOWNSTREAM_ADDR\n value: \"b\"\n - name: HEADERS\n value: \"x-request-id\"\n ports:\n - containerPort: 8080\n resources:\n limits:\n cpu: {{.cpu}}\n memory: 122Mi\n",
"variable_yaml":[
{
"key":"cpu",
"value":"12m",
"desc":"cpu value",
"type":"string"
}
]
}
2
3
4
5
6
7
8
9
10
11
12
Return
{
"message": "success"
}
2
3
# Update Service Configuration
# Test Service
# Request
PUT /openapi/service/yaml/:serviceName?projectKey=<project_name>
# Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
# Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
# Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
type | Service type, specify as k8s | string | Yes |
yaml | Service configuration YAML content | string | Yes |
Body Parameter Example
Details
{
"type":"k8s",
"yaml":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service1\n labels: \n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n spec:\n containers:\n - name: service1\n image: koderover.******.com/koderover-demo/service1:latest\n imagePullPolicy: Always \n command:\n - /workspace/service1\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service1\n labels:\n app.kubernetes.io/name: yaml-poc\n app.kubernetes.io/instance: service1\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}\n",
}
2
3
4
# Return
{
"message": "success"
}
2
3
# Production Service
Request
PUT /openapi/service/yaml/production/:serviceName?projectKey=<project_name>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
type | Service type, specify as k8s | string | Yes |
yaml | Service configuration YAML content | string | Yes |
Body Parameter Example
Details
{
"type":"k8s",
"yaml":"apiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: service1\n labels: \n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\nspec:\n selector:\n matchLabels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n replicas: 1\n template:\n metadata: \n labels:\n app.kubernetes.io/name: demo\n app.kubernetes.io/instance: service1\n spec:\n containers:\n - name: service1\n image: koderover.******.com/koderover-demo/service1:latest\n imagePullPolicy: Always \n command:\n - /workspace/service1\n ports:\n - protocol: TCP\n containerPort: {{.port}}\n resources:\n limits:\n memory: {{.memoryLimit}}\n cpu: {{.cpuLimit}}\n---\napiVersion: v1\nkind: Service\nmetadata:\n name: service1\n labels:\n app.kubernetes.io/name: yaml-poc\n app.kubernetes.io/instance: service1\nspec:\n type: NodePort\n ports:\n - protocol: TCP\n port: {{.port}}\n targetPort: {{.port}}\n",
}
2
3
4
Return
{
"message": "success"
}
2
3
# Update Service Variable
# Test Service
Request
PUT /openapi/service/yaml/:serviceName/variable?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_variable_kvs | Service variable list | []KeyVal | Yes |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Body Parameter Example
Details
{
"service_variable_kvs": [
{
"key":"cpu",
"value":"12m",
"type":"string",
"options":[],
"desc":""
}
]
}
2
3
4
5
6
7
8
9
10
11
Return
{
"message": "success"
}
2
3
# Production Service
Request
PUT /openapi/service/yaml/production/:serviceName/variable?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Body Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
service_variable_kvs | Service variable list | []KeyVal | Yes |
KeyVal Parameter Description
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable key | string | Yes |
value | Variable value, if there is nested value, use json format | any | Yes |
type | Variable value type, there are four types: bool, string, enum, yaml | string | Yes |
options | Variable optional value list, this field has meaning when type is enum | []string | No |
desc | Variable description information | String | No |
Body Parameter Example
Details
{
"service_variable_kvs": [
{
"key":"cpu",
"value":"12m",
"type":"string",
"options":[],
"desc":""
}
]
}
2
3
4
5
6
7
8
9
10
11
Return
{
"message": "success"
}
2
3
# Delete Service
# Test Service
# Request
DELETE /openapi/service/yaml/<serviceName>?projectKey=<projectKey>
# Return
{
"message": "success"
}
2
3
# Production Service
Request
DELETE /openapi/service/yaml/production/:serviceName?projectKey=<projectKey>
Path Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
serviceName | string | Service name | Yes |
Query Parameter Description
| Parameter Name | Type | Description | Required |
|---|---|---|---|
projectKey | string | Project Key | Yes |
Return
{
"message": "success"
}
2
3
# Create Helm Service from Template
Request
POST /openapi/service/template/load/helm?projectKey=<projectKey>
Body Parameters
| Parameter Name | Description | Type | Required |
|---|---|---|---|
project_key | Project Key | string | Yes |
service_name | Service Name | string | Yes |
production | Is Production Environment | bool | No |
template_name | Helm Template Name | string | Yes |
values_yaml | Values YAML Content | string | No |
variables | Template Variable Info | []KeyVal | No |
auto_sync | Auto Sync Switch | bool | No |
KeyVal Parameters
| Parameter Name | Description | Type | Required |
|---|---|---|---|
key | Variable Key | string | Yes |
value | Variable Value, use json format if nested | any | Yes |
Body Parameter Example
Create service api-test for project multi-chart using template general-chart:
Details
{
"auto_sync": true,
"production": false,
"project_key": "multi-chart",
"service_name": "api-test",
"template_name": "general-chart",
"values_yaml": "aa: bb\ncc: dd",
"variables": [
{
"key": "port",
"value": 20012
}
]
}
2
3
4
5
6
7
8
9
10
11
12
13
14
Response
{
"message": "success"
}
2
3


